import { prop, modelOptions,Ref } from '@typegoose/typegoose';
import { ApiProperty } from '@nestjs/swagger';
import { Episode } from './episode.model';

  // 给添加的数据加入时间戳
@modelOptions({
  schemaOptions:{
      timestamps:true,
      toJSON:{ virtuals:true },
      toObject:{ virtuals:true }
  }
})
    
// 课程的模型类
  export class Course{
  
    @ApiProperty({description:'课程名称',example:'kechengcc'})
    @prop()
    name: string
  
    @ApiProperty({description:'封面图',example:'fengmianbb'})
    //必须有prop 才能定义模型类的字段
    @prop()
    cover: string

    //数组字段
    @prop({ 
      ref:'Episode',
      // localField:'_id',
      // foreignFied:'course'
    })
    //课时 关联数据
    episodes:[string]
  }